import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';

//route
import { reduxReactRouter, routerStateReducer, ReduxRouter,pushState } from 'redux-router';
import { createHistory } from 'history';
//import { Route } from 'react-router';

//redux
import { combineReducers, applyMiddleware, compose, createStore } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { Provider } from 'react-redux';

import appReducer from './reducers';
const reducer = combineReducers({router:routerStateReducer,app:appReducer});

/**
*middleware 最优秀的特性就是可以被链式组合。你可以在一个项目中使用多个独立的第三方 middleware。
*异步请求时，需要增加一个thunkMiddleware来重新包装dispatch
*compose(...functions) 从右到左来组合多个函数，把多个store增强器依次执行，
*   返回值(Function): 从右到左把接收到的函数合成后的最终函数。
**/
const store = compose(
  applyMiddleware(thunkMiddleware),
  reduxReactRouter({createHistory})
)(createStore)(reducer);



import routes from './routes';//按需加载

ReactDOM.render(
(<div>
  <Provider store={store}>
      <ReduxRouter routes={routes} />
  </Provider>
</div>),
document.getElementById('container_panel')
);